Skip to content

dependency_currency: collapse transitive npm outdated rows per lockfile - #2276

Merged
remigiusz-antczak merged 1 commit into
mainfrom
dc-collapse-land
Nov 9, 2026
Merged

remigiusz-antczak merged 1 commit into
mainfrom
dc-collapse-land

Conversation

@remigiusz-antczak

Copy link
Copy Markdown
Collaborator

BLUF: On a real repo from an 83-repo audit corpus, the dependency_currency.py TSV output drops from 699 to 60 "outdated" rows. Transitive npm packages now collapse into one row per lockfile, and the 48 vulnerable and 2 end-of-life rows are unchanged.

Why

Across the corpus, 2,358 of 2,664 dep-currency "outdated" rows were transitive packages in npm lockfiles. They are not directly actionable, because they move when the direct dependencies that pull them in are upgraded. They also buried the direct and vulnerable rows.

What changes

  • In TSV output only, when a lockfile has more than 3 outdated transitive npm packages, they print as one outdated row. That row is at the smallest line and gives:

    • the count;
    • how many are a major version behind;
    • the first 3 names.

    --json still lists every row.

  • Lockfiles covered: package-lock.json, npm-shrinkwrap.json, yarn.lock and pnpm-lock.yaml.

  • Direct dependencies are read from:

    • the sibling package.json;
    • the root and workspace entries of a package-lock v2/v3;
    • the pnpm importers.
  • The change fails safe. Nothing collapses in these cases:

    • the direct set cannot be read;
    • a yarn.lock sits beside a package.json that declares workspaces, because workspace manifests are not read;
    • reading the direct set raises an error. The TSV output is not dropped in that case.
  • Direct, vulnerable, kev and eol rows are unchanged.

  • The collapsed message has tabs and newlines replaced, like every other TSV row.

Review

An independent review found 2🔴, 2🟡 and 1🔵.

  • Fixed in this PR:
    • TSV tab and newline in package names;
    • yarn workspaces folding direct dependencies into the summary;
    • the narrow except, which could crash the whole TSV output;
    • the yarn and malformed-input test gaps.
  • No change: the 🔵, which is a small overlap with the lockfile parse in collect().

Tests

  • New: scripts/test_dependency_currency_transitive_collapse.py, 10/10. Two of its tests (tab in a name, yarn workspaces) fail before the fold.
  • All dependency-currency suites pass.
  • All 346 per-PR CI test registrations pass on this exact tree (346/346), run from a path outside .claude/worktrees.
  • Gates are clean:
    • privacy (both banlists);
    • size ratchet;
    • routing;
    • version;
    • git diff --check;
    • SHA256SUMS.

🤖 Generated with Claude Code

On an 83-repo audit corpus, 2,358 of 2,664 dep-currency "outdated" rows
were transitive packages in npm lockfiles. They are not directly
actionable, because they move when the direct dependencies that pull
them in are upgraded, and they buried the direct and vulnerable rows.

TSV output now prints the outdated rows of transitive npm packages as
one outdated row per lockfile when there are more than 3. The row gives
the count, how many are a major version behind, and the first 3 names;
--json still lists every one. The lockfiles covered are
package-lock.json, npm-shrinkwrap.json, yarn.lock and pnpm-lock.yaml.

The direct set comes from three sources:
- the sibling package.json;
- the root and workspace entries of a package-lock v2/v3;
- the pnpm importers.
Nothing collapses in these cases:
- the direct set cannot be read;
- a yarn.lock sits beside a package.json that declares workspaces,
  because workspace manifests are not read.
Direct, vulnerable, kev and eol rows are unchanged. Collapsed messages
have tabs and newlines replaced, like every other TSV row. A failure
while reading the direct set falls back to no collapse rather than
dropping the TSV output.

On a real corpus repo, outdated rows go from 699 to 60, and the 48
vulnerable and 2 eol rows are unchanged.

Tests: 346/346

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@remigiusz-antczak
remigiusz-antczak merged commit 73fa092 into main Nov 9, 2026
11 checks passed
@remigiusz-antczak
remigiusz-antczak deleted the dc-collapse-land branch November 9, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant